#pragma once
#include <cstdint>
#include <unistd.h>

namespace xncc {
namespace sys {
    class EventFd
    {
      public:
        EventFd();
        ~EventFd();
        EventFd(EventFd&&) = default;

        EventFd(const EventFd&)            = default;
        EventFd& operator=(const EventFd&) = default;
        EventFd& operator=(EventFd&&)      = default;

        [[nodiscard]] int     Fd() const { return event_fd_; }
        ssize_t               read(uint64_t& flag) const;
        [[nodiscard]] ssize_t write(uint64_t flag = 1) const;

      private:
#if defined(__CYGWIN__)
        int pipe_fd_[2];
#endif
        int event_fd_;
    };
}  // namespace sys
}  // namespace xncc